# 论坛回帖
from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep
from options import options

url = r'http://192.168.183.140/upload/'
driver = webdriver.Chrome(options=options)
driver.get(url)
# 窗口最大化
driver.maximize_window()

# 登录
driver.find_element(By.ID, 'ls_username').clear()
driver.find_element(By.ID, 'ls_username').send_keys('admin')
driver.find_element(By.ID, 'ls_password').clear()
driver.find_element(By.ID, 'ls_password').send_keys('123456')
driver.find_element(By.XPATH, '/html/body/div[5]/div/div[1]/form/div/div/table/tbody/tr[2]/td[3]/button/em').click()
sleep(3)

# 进入默认板块
driver.find_element(By.XPATH, '//*[@id="category_1"]/table/tbody/tr[1]/td[2]/h2/a').click()
# 打开帖子  copy selector使用层级
driver.find_element(By.CSS_SELECTOR, '#normalthread_805 > tr > th > a.s.xst').click()
sleep(3)
# 回复帖子
driver.find_element(By.CSS_SELECTOR, '#post_reply > img').click()
sleep(3)
driver.find_element(By.XPATH, '//*[@id="postmessage"]').clear()
driver.find_element(By.XPATH, '//*[@id="postmessage"]').send_keys('回帖1')
sleep(3)
driver.find_element(By.CSS_SELECTOR, '#postsubmit > span').click()
sleep(3)

# 退出
driver.find_element(By.LINK_TEXT, '退出').click()
sleep(3)

driver.quit()
